package com.macro.mall.portal.sms;

import cn.hutool.core.util.StrUtil;
import com.macro.mall.common.enums.SourceTypeEnum;
import com.macro.mall.common.enums.StatusEnum;
import com.macro.mall.model.SmsMessageHistory;
import lombok.Data;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author：郎
 * @name：SmsTencentMessage
 * @date：2023/12/11 18:59
 */
@Data
public class SmsLocalMessage implements SmsMessage {
    private final Log logger = LogFactory.getLog(SmsLocalMessage.class);
    /**
     * 单位是分钟
     */
    private String expiredTime;

    @Override
    public Long getExpireTimeSecond() {
        if (StrUtil.isBlank(expiredTime)) {
            return 120L;
        } else {
            return Integer.parseInt(expiredTime) * 60L;
        }
    }

    @Override
    public SmsMessageHistory sendMessage(String phone, String verifyCode) {
        SmsMessageHistory smsMessageHistory = new SmsMessageHistory();
        smsMessageHistory.setCode(verifyCode);
        smsMessageHistory.setPhone(phone);
        smsMessageHistory.setExpiredMinute(expiredTime);
        smsMessageHistory.setSourceType(SourceTypeEnum.LOCAL.getCode());
        smsMessageHistory.setStatus(StatusEnum.SUCCESS.getCode());
        return smsMessageHistory;
    }

    @Override
    public Object getResponseStatus() {
        return null;
    }
}
